home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdedmodule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.7 KB  |  149 lines

  1. /*
  2.    This file is part of the KDE libraries
  3.  
  4.    Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
  5.  
  6.    This library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Library General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2 of the License, or (at your option) any later version.
  10.  
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Library General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Library General Public License
  17.    along with this library; see the file COPYING.LIB.  If not, write to
  18.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.    Boston, MA 02110-1301, USA.
  20.  
  21. */
  22. #ifndef __KDEDMODULE_H__
  23. #define __KDEDMODULE_H__
  24.  
  25. #include <qobject.h>
  26. #include <dcopobject.h>
  27. #include <ksharedptr.h>
  28.  
  29. class KDEDModulePrivate;
  30. class Kded;
  31.  
  32. /**
  33.  * The base class for KDED modules.
  34.  *
  35.  * In KDE 2 and KDE 3, KDED modules are realized as shared
  36.  * libraries that are loaded on-demand into kded at runtime.
  37.  *
  38.  * To write a config module, you have to create a library
  39.  * that contains at least one factory function like this:
  40.  *
  41.  * \code
  42.  *   extern "C" {
  43.  *     KDE_EXPORT KDEDModule *create_xyz(QCString *name)
  44.  *     {
  45.  *       return new XYZ(name);
  46.  *     }
  47.  *   }
  48.  * \endcode
  49.  *
  50.  * See kdelibs/kded/HOWTO for more detailed documentation.
  51.  *
  52.  * @author Waldo Bastian <bastian@kde.org>
  53.  */
  54.  
  55. class KDE_EXPORT KDEDModule : public QObject, public DCOPObject
  56. {
  57.   Q_OBJECT
  58. // For inclusion in KDE4 (since it's BIC) long-needed fix for allowing
  59. // DCOP-based kdedmodules -- Gav <gav@kde.org>.
  60. //  K_DCOP
  61.   friend class Kded;
  62. public:
  63.   
  64.   /**
  65.    * Create a DCOPObject named @p name
  66.    */
  67.   KDEDModule(const QCString &name);
  68.   
  69.   virtual ~KDEDModule();
  70.   
  71.   /**
  72.    * Specifies the idle timeout in seconds. The default is 0. 
  73.    *
  74.    * This will call the idle slot @p secs seconds after the last 
  75.    * reference was removed.
  76.    */
  77.   void setIdleTimeout(int secs);
  78.  
  79.   /**
  80.    * Reset the idle timeout counter. 
  81.    *
  82.    * (re)starts the timeout counter if no objects are being referenced.
  83.    */
  84.   void resetIdle();
  85.  
  86.   /**
  87.    * Insert @p obj indexed with @p app and @p key. The
  88.    * object will be automatically deleted when the application
  89.    * @p app unregisters with DCOP.
  90.    *
  91.    * Any previous object inserted with the same values for @p app 
  92.    * and @p key will be removed.
  93.    */
  94.   void insert(const QCString &app, const QCString &key, KShared *obj);
  95.  
  96.   /**
  97.    * Lookup object indexed with @p app and @p key
  98.    */
  99.   KShared *find(const QCString &app, const QCString &key);
  100.   
  101.   /**
  102.    * remove object indexed with @p app and @p key.
  103.    * The object will be deleted when it is no more referenced.
  104.    */
  105.   void remove(const QCString &app, const QCString &key);
  106.  
  107.   /**
  108.    * remove all objects indexed with @p app. 
  109.    * The objects will be deleted when they are no more referenced.
  110.    */
  111.   void removeAll(const QCString &app);
  112.  
  113.   /**
  114.    * Returns whether a certain mainwindow has registered itself with KDED
  115.    */
  116.   bool isWindowRegistered(long windowId);
  117.   
  118. public slots:
  119.   /**
  120.    * Called whenever the last referenced object gets dereferenced.
  121.    *
  122.    * See also setIdleTimeout()
  123.    *
  124.    * You may delete the module from this slot.
  125.    */
  126.   virtual void idle() { };
  127.  
  128. signals:
  129.   /**
  130.    * Emitted when the module is being deleted.
  131.    */
  132.   void moduleDeleted(KDEDModule *);
  133.  
  134.   /**
  135.    * Emitted when a mainwindow registers itself.
  136.    */
  137.   void windowRegistered(long windowId);
  138.  
  139.   /**
  140.    * Emitted when a mainwindow unregisters itself.
  141.    */
  142.   void windowUnregistered(long windowId);
  143.  
  144. private:
  145.   KDEDModulePrivate *d;
  146. };
  147.  
  148. #endif
  149.